package com.mzba.peng;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

/**
 * @author mzba
 * @site http://06peng.com
 *
 */
public class QuickActionActivity extends Activity {
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ((Button) findViewById(R.id.btn)).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				quickActionMenu(v);
			}
		});
    }
    
    private void quickActionMenu(View v) {
    	ActionItem openAction = new ActionItem();
		openAction.setTitle("打开");
		openAction.setIcon(getResources().getDrawable(R.drawable.icon));
		ActionItem callAction = new ActionItem();
		callAction.setTitle("呼叫");
		callAction.setIcon(getResources().getDrawable(R.drawable.icon));
		ActionItem smsAction = new ActionItem();
		smsAction.setTitle("发送短信");
		smsAction.setIcon(getResources().getDrawable(R.drawable.icon));

		final QuickAction mQuickAction = new QuickAction(this);
		mQuickAction.addActionItem(openAction);
		mQuickAction.addActionItem(callAction);
		mQuickAction.addActionItem(smsAction);
		mQuickAction
				.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
					@Override
					public void onItemClick(int pos) {
						switch (pos) {
						case 0: 
							Toast.makeText(QuickActionActivity.this, "open", Toast.LENGTH_LONG).show();
							break;
						case 1: 
							Toast.makeText(QuickActionActivity.this, "call", Toast.LENGTH_LONG).show();
							break;
						case 2:
							Toast.makeText(QuickActionActivity.this, "sendSms", Toast.LENGTH_LONG).show();
							break;
						}
					}
				});
		mQuickAction.show(v);
    }
}